package com.xumingxun.aibox.execute;

import com.xumingxun.aibox.config.LanguageConfig;
import com.xumingxun.aibox.domain.node.Node;
import com.xumingxun.aibox.domain.node.StartNode;

public class ExecuteService {

    public Object execute(StartNode startNode,String message){
        startNode.getContext().setRuntimeVarValue(startNode.getQuestionVar(),message);

        Node node=startNode;
        do{
            Node nextNode=node.execute();
            if(node.isExport()) {
                return node.getResult();
            }
            node=nextNode;
        }while(node!=null);

        return LanguageConfig.getConfig(LanguageConfig.DEFAULT_RESPONSE);
    }

}
